module Security
  module Encryption
    require_dependency "openssl"
    require_dependency "base64"

    protected
      def self.encrypt(value)
        cr = value.dup
        if value.length < 24
          for i in value.length..23
            cr += "0"
            cr[i] = 0
          end
        end

        for i in 0..23
          cr[i] ^= SECURITY_SALT[i]
        end
        sha = OpenSSL::Digest::SHA1.new
        sha << cr
        Base64.encode64(sha.digest).strip
      end#encrypt
  end
end
